<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .parent {
            display: flex;
            width: 500px;
            height: 230px;
            outline: 2px dotted;
            background-color: #fff;
        }
        .item {
            background: orange;
            border: 1px solid #333;
        }
        .item img {
            max-width: 100%;
            object-fit: contain;
        }
    </style>
</head>
<body>
    <br>
    <p>flex容器有3个子元素, 下列选择选择后，作用与第二个flex 子项。</p>
    <pre>flex: none | auto | [<'flex-grow'><'flex-shrink'>? || <'flex-basis'>]</pre>
    <form action="#" onsubmit="return false;">
        <label for=""><input type="radio" name="option" value="" data-attr="flex">flex: 默认值;(flex: 0 1 auto; 不扩展，会缩小，无默认宽度)</label><br>
        <label for=""><input type="radio" name="option" value="none" data-attr="flex">flex: none;(flex: 0 0 auto;)不扩展，不缩小，无默认宽度</label><br>
        <label for=""><input type="radio" name="option" value="auto" data-attr="flex">flex: auto;(flex: 1 1 auto;)会扩展，会缩小，无默认宽度</label><br>
        <label for=""><input type="radio" name="option" value="1" data-attr="flex">flex: 1; （flex-grow值为1，flex-shrink 和 flex-basis取默认值。效果等同flex: 1 1 auto;）</label>
    </form>
    <br>
    <div class="parent">
        <div class="item"><img src="./images/01.jpeg" alt=""></div>
        <div class="item item2"><img src="./images/02.jpeg" alt=""></div>
        <div class="item"><img src="./images/03.jpeg" alt=""></div>
    </div>
    <script>
        let inputs = document.querySelectorAll('input[name=option]');
        let box = document.querySelector('.item2');
        Array.from(inputs).forEach((ele, i) => {
            ele.onchange = function() {
                let value = this.value;
                let prop = this.dataset.attr;
                box.style[prop] = value;
            }
        })
    </script>
</body>
</html>